﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
/**
* @Author: AdinZ
* @Q  Q : 1454269
* @Email:adinz@adinz.com
* @Created: 2014/3/30 9:55:31
* */
namespace Reader.Web.api
{
    /// <summary>
    /// api 的摘要说明
    /// </summary>
    public class api : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            context.Response.Write(Api.Action.action(getRequest(context)));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// 获取常用url参数
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private Dictionary<string, string> getRequest(HttpContext context)
        {
            string action = context.Request["action"];
            string type = context.Request["type"];
            string imei = context.Request["imei"];
            string version = context.Request["version"];
            string model = context.Request["model"];
            string os = context.Request["os"];
            string os_name = context.Request["os_name"];
            string screen_size = context.Request["screen_size"];
            string page = context.Request["page"];
            string id = context.Request["id"];
            string session = context.Request["session"];
            string uid = context.Request["uid"];
            string bookid = context.Request["bookid"];
            string chapterid = context.Request["chapterid"];
            string payment = context.Request["payment"];
            string name = context.Request["name"];
            string passwd = context.Request["passwd"];
            string email = context.Request["email"];
            string phone = context.Request["phone"];
            string cu = context.Request["cu"];
            string vid = context.Request["vid"];
            string pid = context.Request["pid"];
            string firm = context.Request["firm"];
            string kernel = context.Request["kernel"];
            string ispay = context.Request["ispay"];
            string sgin = context.Request["sgin"];

            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            dictionary.Add("action", action);
            dictionary.Add("type", type);
            dictionary.Add("imei", imei);
            dictionary.Add("version", version);
            dictionary.Add("model", model);
            dictionary.Add("os", os);
            dictionary.Add("os_name", os_name);
            dictionary.Add("screen_size", screen_size);
            dictionary.Add("page", page);
            dictionary.Add("id", id);
            dictionary.Add("session", session);
            dictionary.Add("uid", uid);
            dictionary.Add("bookid", bookid);
            dictionary.Add("chapterid", chapterid);
            dictionary.Add("payment", payment);
            dictionary.Add("passwd", passwd);
            dictionary.Add("name", name);
            dictionary.Add("email", email);
            dictionary.Add("phone", phone);
            dictionary.Add("cu", cu);
            dictionary.Add("agent", context.Request.Headers["User-Agent"]);
            dictionary.Add("pid", pid);
            dictionary.Add("vid", vid);
            dictionary.Add("firm", firm);
            dictionary.Add("kernel", kernel);
            dictionary.Add("ispay", ispay);
            dictionary.Add("sgin", sgin);
            return dictionary;
        }








    }
}